const express = require('express');
const router = express.Router();
const db = require("../../../util/dbConfig/dbConfig")

//根据id查找并删除user表的该id的信息
router.delete('/',async (req,res)=> {
    let {id} = req.body
    //如果没有id值，返回参数错误
    if(!id){
        return res.send({
            code: 1,
            msg: '参数错误，请输入有效id'
        })
    }
    //有id值
    try{
        let sql = `update user set ISDELETE=? where ID=?`
        let sqlArr = [1,id]
        let callBack = (err,data)=>{
            if(err){
                console.log(err);
            }else{
                return res.send({
                    code: 0,
                    msg: '删除成功'
                })
            }
        }
        db.sqlConnect(sql,sqlArr,callBack)
    }catch (e) {
        console.log(e);
        return res.send({
            code: 4,
            msg: '服务器错误'
        })
    }
})

module.exports = router
